import { getOrders } from "api/api"
export default {
    state: {
        orders: []
    },
    getters: {

    },
    mutations: {
        getOrders(state, orders) {
            state.orders = orders
        }
    },
    actions: {
        //获取订单列表
        async getOrders(store, { page, limit }) {
            try {
                const { code, data } = await getOrders(page, limit);
                if (code === 200) {
                    store.commit("getOrders", data.records)
                }
                return { code, total: data.total }
            } catch (e) {
                return Promise.reject(e)
            }
        }
    }
}
